﻿using UnityEngine;
using System;
using System.Collections;

public class Constants : MonoBehaviour {
    // 상수 설정
    public const float PI = 3.141592f; // 등등등
    public const byte CharRareMax = 6;

    public const short FormationKind = 3;
    public const short FormationNum = 21;

    public const int EnhanceKina = 150;

    static public int[] BundleNeedMemory = null;
    static public Color[] CharInfoRareColor = null;
    static public Color[] CharInfoRareColorBG = null;

    static public void InitConstants()
    {
        //카드 덱 랭크 포인트 이름
        if (BundleNeedMemory == null)
        {
            BundleNeedMemory = new int[(int)BundleIndex.max];            
        }

        if(CharInfoRareColor == null)
        {
            CharInfoRareColor = new Color[CharRareMax];
            CharInfoRareColor[0] = new Color(0, 0, 0);
            CharInfoRareColor[1] = new Color(0, 1, 138f / 255f);
            CharInfoRareColor[2] = new Color(0, 168f / 255f, 1);
            CharInfoRareColor[3] = new Color(1, 246f / 255f, 0);
            CharInfoRareColor[4] = new Color(1, 90f / 255f, 0);
            CharInfoRareColor[5] = new Color(120f / 255f, 0, 1);
        }

        if (CharInfoRareColorBG == null)
        {
            CharInfoRareColorBG = new Color[CharRareMax];
            CharInfoRareColorBG[0] = new Color(0, 0, 0);
            CharInfoRareColorBG[1] = new Color(0, 145f / 255f, 78f / 255f);
            CharInfoRareColorBG[2] = new Color(0, 168f / 255f, 1);
            CharInfoRareColorBG[3] = new Color(1, 222f / 255f, 0);
            CharInfoRareColorBG[4] = new Color(1, 90f / 255f, 0);
            CharInfoRareColorBG[5] = new Color(120f / 255f, 0, 1);
        }
    }

	#region Static Function
	public static DateTime ConvertFromUnixTimestamp(double timestamp)
	{
		DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
		return origin.AddMilliseconds(timestamp).ToLocalTime();
	}
	
	public static double ConvertToUnixTimestamp(DateTime date)
	{
		DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0);
		return (date - origin).TotalSeconds;
	}
	#endregion

//	public static long SCTimeOffest = 0f                  ;

    



    //public static Color GetCharacterRareColor(int rare)
    //{
    //    Color color = new Color();
    //    switch (rare)
    //    {
    //        case 1:
    //            color = new Color(4f / 255f, 246f / 255f, 105f / 255f);
    //            break;
    //        case 2:
    //            color = new Color(10f / 255f, 196f / 255f, 242f / 255f);
    //            break;
    //        case 3:
    //            color = new Color(255f / 255f, 222f / 255f, 0f / 255f);
    //            break;
    //        case 4:
    //            color = new Color(255f / 255f, 90f / 255f, 0f / 255f);
    //            break;
    //        case 5:
    //            color = new Color(149f / 255f, 56f / 255f, 0f / 255f);
    //            break;
    //    }

    //    return color;
    //}

	public static Color GetItemGlowRareColorValue(int rare)
	{
	Color color = new Color();
		switch (rare)
		{
		case 1:
			color = new Color(4f/255f, 246f/255f, 105f/255f);
			break;
		case 2:
			color = new Color(10f/255f, 196f/255f, 242f/255f);
			break;
		case 3:
			color = new Color(255f/255f, 222f/255f, 0f/255f);
			break;
		case 4:
			color = new Color(255f/255f, 90f/255f, 0f/255f);
			break;
		case 5:
			color = new Color(149f/255f, 56f/255f, 0f/255f);
			break;
		}

		return color;
	}

	public static Color GetItemBGRareColorValue(int rare)
	{
		Color color = new Color();
		switch (rare)
		{
		case 0:
			color = new Color(140f/255f, 220f/255f, 230f/255f);
			break;
		case 1:
			color = new Color(0f/255f, 180f/255f, 80f/255f);
			break;
		case 2:
			color = new Color(0f/255f, 120f/255f, 210f/255f);
			break;
		case 3:
			color = new Color(210f/255f, 200f/255f, 0f/255f);
			break;
		case 4:
			color = new Color(255f/255f, 150f/255f, 30f/255f);
			break;
		case 5:
			color = new Color(210f/255f, 130f/255f, 255f/255f);
			break;
		}
		
		return color;
	}

	public static Color[] GetItemWindowDecoColorValue(int rare)
	{
		Color[] color = new Color[2];
		switch (rare)
		{
		case 0:
			color[0] = new Color(126f/255f, 164f/255f, 176f/255f);
			color[1] = new Color(134f/255f, 142f/255f, 142f/255f);
			break;
		case 1:
			color[0] = new Color(0f/255f, 255f/255f, 149f/255f);
			color[1] = new Color(10f/255f, 139f/255f, 96f/255f);
			break;
		case 2:
			color[0] = new Color(0f/255f, 181f/255f, 255f/255f);
			color[1] = new Color(7f/255f, 117f/255f, 161f/255f);
			break;
		case 3:
			color[0] = new Color(255f/255f, 227f/255f, 0f/255f);
			color[1] = new Color(133f/255f, 113f/255f, 1f/255f);
			break;
		case 4:
			color[0] = new Color(255f/255f, 164f/255f, 0f/255f);
			color[1] = new Color(142f/255f, 92f/255f, 0f/255f);
			break;
		case 5:
			color[0] = new Color(157f/255f, 64f/255f, 25f/255f);
			color[1] = new Color(79f/255f, 37f/255f, 50f/255f);
			break;
		}
		
		return color;
	}

	public static string GetItemWindowSpriteName(int rare)
	{
		string spritName = "";
		switch (rare)
		{
		case 0:
			spritName = "img_item_level_bg_06";
			break;
		case 1:
			spritName = "img_item_level_bg_05";
			break;
		case 2:
			spritName = "img_item_level_bg_04";
			break;
		case 3:
			spritName = "img_item_level_bg_03";
			break;
		case 4:
			spritName = "img_item_level_bg_02";
			break;
		case 5:
			spritName = "img_item_level_bg_01";
			break;
		}
		return spritName;
	}
}
